//
//  ColumnCollectionReusableView.m
//  UI-14-HomeWorkLws
//
//  Created by GivenBmli on 16/8/2.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "ColumnCollectionReusableView.h"
#import "imageViewColumn.h"
#define kCollectionReuse @"resueSmall"
@interface ColumnCollectionReusableView ()<UICollectionViewDataSource , UICollectionViewDelegate>

@property(nonatomic , strong)UICollectionView *collectionView;
@property(nonatomic , strong)UILabel *label;

@end


@implementation ColumnCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, 50)];
        label1.text = @"栏目";
        [self addSubview:label1];
        UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
        CGFloat height = CGRectGetHeight(frame)-50 -40;
        flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        flow.itemSize = CGSizeMake((CGRectGetWidth(frame) - 30 ) / 2, height / 3);
        flow.minimumLineSpacing = 10;
        flow.minimumInteritemSpacing = 0;
        flow.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        
        
        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 50, CGRectGetWidth(frame), CGRectGetHeight(frame)-50)collectionViewLayout:flow];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.pagingEnabled = YES;
        _collectionView.backgroundColor = [UIColor whiteColor];
        [self addSubview:_collectionView];
        [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:kCollectionReuse];
//          [_colletiView registerClass:[imageCollectionViewCell class] forCellWithReuseIdentifier:kCollectionViewReture];
        [_collectionView registerClass:[imageViewColumn class] forCellWithReuseIdentifier:kCollectionReuse];
        
    }
    return self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 20;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    imageViewColumn *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionReuse forIndexPath:indexPath];
    
    return cell;
}

@end
